package _go
/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
func invertTree(root *TreeNode) *TreeNode {
	return dg(root)
}

func dg(root *TreeNode)  *TreeNode {
	if root == nil { return root}
	L := dg(root.Left)//翻转左子树
	R := dg(root.Right)//翻转右子树

	//交换左右子树
	root.Left = R
	root.Right = L
	return root
}